package com.zyg.search.controller;

import com.zyg.search.entity.ItemVo;
import com.zyg.search.service.ItemSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 * 作者: LMY
 * 功能: XX
 * 创建时间: 2021-11-02 21:23
 **/
@Controller
public class SearchController {

   @Autowired
   private ItemSearchService searchService;

  /**
   * 作者 : LMY
   * 功能 : 条件查询
   * 时间 : 2021/11/2 21:41
   */ 
   @GetMapping({"/","/search.html"})
    public String search(Model model, ItemVo params){
       //1. 开始进行条件查询
       Map<String,Object> resultMap = searchService.search(params);
       //2. 查询结果存储到model中
       model.addAttribute("resultMap",resultMap);
       //3. 将查询也存入model中
       model.addAttribute("vo",params);
       //4. 返回到物理视图
       return "search";
   }
}
